home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / misc / zvm1_25.lha / showfax.zvm < prev    next >
Text File  |  1993-09-27  |  13KB  |  472 lines

  1. /*showfax.zvm*/
  2. /* DANGER!!! DO NOT EDIT ANYTHING THAT IS NOT PART OF THE USER-CODE SECTION!!! */
  3.  
  4. /* THIS PART IS INCLUDED FROM INCLUDEH.ZVM.  DO NOT EDIT THIS PART.  LOOK FOR
  5.    THE SECTION WHICH SAYS USER CODE SECTION.  YOU HAVE BEEN WARNED!
  6.     
  7.    V1.00
  8. */
  9.  
  10. /* we want results! */
  11. options results
  12.  
  13. /* We want to trap on these things, to help us debug.  The definitions for
  14.    these are in INLCUDET.ZVM
  15. */
  16.  
  17. signal on halt
  18. signal on novalue
  19. signal on syntax
  20. signal on break_c
  21.  
  22. /* Set up modem stuff */
  23. call doInitializations
  24.  
  25. /* We are about to start the user code section.  Any function that you
  26.    write that has a PROCEDURE statement NEEDS to have an EXPOSE MODE. STATUS.
  27.    for my stub functions to work.
  28. */
  29. /*vvvvvvvvvvvvvvvvvvvvvvvvBEGINNING OF USER CODEvvvvvvvvvvvvvvvvvvvvvvvvvv*/
  30.  
  31. /* called with a filename */
  32. parse arg filename
  33.  
  34. address rexx_gpfax 'viewfax' filename
  35.  
  36. exit
  37.  
  38. /*^^^^^^^^^^^^^^^^^^^^^^^^^^END OF USER CODE^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  39. /*-------------------------------HANDS OFF--------------------------------*/
  40. /* DON'T TOUCH THIS STUFF.  IF YOU FIX SOMETHING HERE, TELL ME ABOUT IT   */
  41. /* 
  42.     HISTORY
  43.  
  44.     V1.32    - Added getoption, readoptions, setserial
  45.     V1.31    - Fixed debugger stuff (no value)
  46.     V1.30    - Added debugger stuff
  47.     V1.29    - Fixed type. and log. problem not being exposed
  48.         - Fixed filetype function
  49.     V1.28    - Fixed a problem in callup.  Maybe related to 5.02 roms
  50.     V1.27    - Added filetype rexx function to determine the type
  51.         of a file
  52.     V1.26   - Added some more rexx functions to interface with ZVM
  53.         - Added the callup function to dial a telephone number
  54.     V1.25     - Fixed getnumvoicemessages
  55.     V1.24    - Added requiremode, assumemode, etc.
  56.     V1.23    - Changed the way type and status are handled and added
  57.         a new argument to the get and set stuff (namely, the log number)
  58.         - Also changed to setLogEntryVariable and getLogEntryVariable
  59.         instead of the numerous functions we had before
  60.     V1.22 - Added stuff to make it more programmable
  61. */
  62.  
  63. exit
  64.  
  65. getOption: procedure expose options.
  66.     parse upper arg optionName
  67.     return options.optionName
  68.  
  69. readOptions: procedure expose options.
  70.     firstLine = sourceline(1)
  71.     parse var firstLine '/*' title '.'
  72.     optionsFileName = title || '.options'
  73.     if exists(optionsFileName) then do
  74.         call open('options', optionsFileName, 'r')
  75.         do while ~eof('options')
  76.             line = readln('options')
  77.             parse upper var line variable '=' value
  78.             options.variable = value
  79.         end
  80.         call close('options')
  81.     end
  82.  
  83.     return
  84.  
  85. /* this function dials a number and returns status.normal
  86.     if someone picks up the phone that was called.  It returns
  87.     other types of errors otherwise.
  88. */
  89.  
  90. callup: procedure expose status. mode. device.
  91.     parse arg telephoneNumber
  92.     
  93.     /* should do an at+fclass=8 */
  94.     status = requireMode(mode.voiceMode)
  95.     if status ~= status.normal then return status
  96.  
  97.     status = writeLine('ATD' telephoneNumber)
  98.     if status ~= status.normal then return status
  99.  
  100.     /* this should swallow the thing we just sent out */
  101.     status = readLine(60) /* 60 second timeout */
  102.     if status ~= status.normal then return status
  103.  
  104. ringing:
  105.     status = readLine(60) /* 60 second timeout */
  106.     if status ~= status.normal then return status
  107.  
  108.     /* line should have the line we want */
  109.     if line = 'VCON' then do
  110.         /* removed the next line because even though we received
  111.             a VCON, it doesn't go into voicemode */
  112.         call requireDevice(device.telephoneLine)
  113.         /*
  114.         call assumeMode(mode.connectedMode)
  115.         */
  116.         return status.normal
  117.     end
  118.  
  119.     if line = 'RINGING' then signal ringing
  120.     if line = 'NO CARRIER' then return status.busydetected
  121.     if line = '' then signal ringing
  122.     if line = 'NO DIALTONE' then do
  123.         call showDebugger("I couldn't detect the dialtone")
  124.         return status.busydetected
  125.     end
  126.  
  127.     return status.busyDetected
  128.  
  129. /* This function gives you a simple way of presenting an N key menu
  130.     to the caller
  131.  
  132.     ARGS:  numKeys choiceFileName badChoiceFileName timeOut validChoices
  133.     numBadChoices
  134.  
  135.     numKeys = number of keys wanted
  136.     choiceFileName = file name of the menu
  137.     badChoiceFileName = what to say if caller enters a bad choice
  138.     timeOut = number of seconds allowed before timing out
  139.     validChoices = list of characters that are valid choices
  140.     numBadChoices = number of times you want to present the menu before exiting
  141.  
  142.     RETURNS:  status, choice = valid key
  143. */
  144.  
  145. presentMenu: procedure expose choice status. mode.
  146.     parse arg numKeys,choiceFileName,badChoiceFileName,timeOut,validChoices,numBadChoices .
  147.  
  148.     timesAround = numBadChoices;
  149.  
  150.     do timesAround = numBadChoices to 1 by -1
  151.         status = playVoice(choiceFileName)
  152.  
  153.         if status > status.keyDetected then signal presentMenuDone;
  154.  
  155.         status = readNKeys(numKeys, timeOut)
  156.  
  157.         if status = status.timedOut then do
  158.             call flushPhoneBuffer()
  159.             status = playVoice('voice:voices/Timed Out')
  160.             iterate
  161.         end
  162.         if status ~= status.normal then signal presentMenuDone;
  163.  
  164.         choice = keys
  165.         if pos(choice, validChoices) = 0 then do
  166.             call flushPhoneBuffer()
  167.             status = playVoice(badChoiceFileName)
  168.             iterate
  169.         end
  170.  
  171.         return status.normal
  172.     end
  173.  
  174.     status = status.timedOut
  175. presentMenuDone:
  176.     return status
  177.  
  178. /*----------------------------------------------------------------------*/
  179. /*    Here are the encapsulated functions.  They're responsible for
  180.     communicating with ZVM.  Don't edit or touch them, except for
  181.     bug fixes.
  182. */
  183.  
  184. playVoice:  procedure expose status. mode.
  185.     parse arg fileName
  186.     address voicemail1 'playVoice' fileName
  187.     if rc >= status.busyDetected then
  188.         call showDebugger('playVoice' rc)
  189.     return rc
  190.  
  191. /* this returns a handle to the newly created log entry */
  192. addLogEntry: procedure expose status. mode.
  193.     if arg() ~= 1 then do
  194.         say 'Bad arguments to addLogEntry'
  195.         return 20
  196.     end
  197.     parse arg logNumber
  198.     address voicemail1 'addLogEntry' logNumber
  199.     return result
  200.  
  201. setLogEntryVariable: procedure expose status. mode.
  202.     if arg() ~= 4 then do
  203.         say 'Bad arguments to setLogEntryVariable'
  204.         return 20
  205.     end
  206.     parse arg variable, logNumber, logEntryNumber, logEntryValue
  207.     address voicemail1 'setLogEntryVar' variable ',' || logNumber || ',' || logEntryNumber || ',' || logEntryValue
  208.     return rc
  209.  
  210. getLogEntryVariable: procedure expose status. mode.
  211.     if arg() ~= 3 then do
  212.         say 'Bad arguments to getLogEntryVariable'
  213.         return 'BADBADBAD'
  214.     end
  215.     parse arg variable, logNumber, logEntryNumber
  216.     address voicemail1 'getLogEntryVar' variable ',' || logNumber || ',' || logEntryNumber
  217.     return result
  218.  
  219. getNumVoiceMessages: procedure expose status. mode.
  220.     if arg() ~= 1 then do
  221.         say 'Bad arguments to getNumVoiceMessages'
  222.         return 'BADBADBAD'
  223.     end
  224.     parse arg logNumber
  225.     address voicemail1 'getNumVoiceMessages' logNumber
  226.     return result
  227.  
  228. recordVoice:  procedure expose status. mode.
  229.     parse arg fileName
  230.     address voicemail1 'recordVoice' fileName
  231.     return rc
  232.  
  233. password: procedure expose status. mode.
  234.     address voicemail1 'password'
  235.     return result
  236.  
  237. hasFax: procedure expose status. mode.
  238.     address voicemail1 'hasfax'
  239.     return result
  240.  
  241. playBeep:  procedure expose status. mode.
  242.     parse arg tone1, tone2, duration
  243.     address voicemail1 'playBeep' tone1 ',' tone2 ',' duration
  244.     return rc
  245.  
  246. readNKeys:  procedure expose status. keys mode.
  247.     parse arg numKeys, timeOut
  248.     address voicemail1 'readNKeys' numKeys ',' timeOut
  249.     if rc = status.normal then keys = result
  250.     return rc
  251.  
  252. read1Key:  procedure expose status. key mode.
  253.     parse arg timeOut
  254.     address voicemail1 'read1Key' timeOut
  255.     if rc = status.normal then key = result
  256.     return rc
  257.  
  258. readKeysUntil: procedure expose status. keys mode.
  259.     parse arg terminatingCharacter, maxCharacters, timeOut
  260.     address voicemail1 'readKeysUntil' terminatingCharacter ',' maxCharacters ',' timeOut
  261.     if rc = status.normal then keys = result
  262.     return rc
  263.  
  264. readLine: procedure expose status. line mode.
  265.     parse arg timeOut
  266.     address voicemail1 'readLine' timeOut
  267.     if rc = status.normal then line = result
  268.     return rc
  269.  
  270. quickATCommand: procedure expose status. mode.
  271.     parse arg command, timeout, errorLine
  272.     if arg(2, 'o') then timeout = 5
  273.     if arg(3, 'o') then errorLine = 'ERROR'
  274.  
  275.     rc = writeLine(command)
  276.     if rc ~= status.normal then return rc
  277.     rc = readLine(timeout)
  278.     if rc ~= status.normal then return rc
  279.     rc = readLine(timeout)
  280.     if line = errorLine then return status.error
  281.     return rc
  282.  
  283. writeLine: procedure expose status. mode.
  284.     parse arg line
  285.     address voicemail1 'writeLine' line
  286.     return rc
  287.  
  288. /* the 'assumeUnknownMode' is to make sure that any use of a voice command WILL
  289.     cause ZVM to hang up the line, reset the modem, then do its stuff */
  290.  
  291. dropLine: procedure expose status. mode.
  292.     address voicemail1 'requireMode' mode.commandMode
  293.     address voicemail1 'assumeUnknownMode'
  294.     return rc
  295.  
  296. atCommands: procedure expose status. mode.
  297.     address voicemail1 'requireMode' mode.connectedMode
  298.     address voicemail1 'assumeUnknownMode'
  299.     return rc
  300.  
  301. requireDevice: procedure expose status. mode.
  302.     parse arg device
  303.     address voicemail1 'requireDevice' device
  304.     return rc
  305.  
  306. requireCompression: procedure expose status. compression.
  307.     parse arg compression
  308.     address voicemail1 'requireCompression' compression
  309.     return rc
  310.  
  311. requireMode: procedure expose status. mode.
  312.     parse arg mode
  313.     address voicemail1 'requireMode' mode
  314.     return rc
  315.  
  316. assumeMode: procedure expose status. mode.
  317.     parse arg mode
  318.     address voicemail1 'assumeMode' mode
  319.     return rc
  320.  
  321. assumeUnknownMode: procedure expose status. mode.
  322.     address voicemail1 'assumeUnknownMode'
  323.     return rc
  324.  
  325. distinctiveRing: procedure expose status. mode.
  326.     address voicemail1 'distinctiveRing'
  327.     return result
  328.  
  329. currentCIDName: procedure expose status. mode.
  330.     address voicemail1 'currentCIDName'
  331.     return result
  332.  
  333. currentCIDNumber: procedure expose status. mode.
  334.     address voicemail1 'currentCIDNumber'
  335.     return result
  336.  
  337. fileType: procedure expose status. mode.
  338.     parse arg filename
  339.     address voicemail1 'filetype' filename
  340.     return result
  341.  
  342. /* handshaking = 1 if you want 7 wire handshaking, handshaking = 2 if you
  343.     want xon/xoff handshaking */
  344. changeSerialParameters: procedure expose status. mode.
  345.     parse arg bps, bits, stop, handshaking
  346.     address voicemail1 'setserial' bps ',' bits ',' stop ',' handshaking
  347.     return rc
  348.  
  349. /* this is mainly for fax mode */
  350. use19200: procedure expose status. mode.
  351.     call changeSerialParameters(19200, 8, 1, 1)
  352.     address voicemail1 'assumeUnknownMode'
  353.     return rc
  354.  
  355. flushPhoneBuffer:  procedure expose status. mode.
  356.     address voicemail1 'flushPhoneBuffer'
  357.     return status.normal
  358.  
  359. listen: procedure expose status. mode.
  360.     address voicemail1 'listen'
  361.     return status.normal
  362.  
  363. answerFax: procedure expose status. mode.
  364.     address rexx 'handleFax'
  365.     return rc
  366.  
  367. cTime: procedure expose status. now mode.
  368.     address voicemail1 'ctime'
  369.     return result
  370.  
  371. displayError: procedure expose status. mode.
  372.     parse arg error
  373.     address voicemail1 'displayError' error
  374.     return status.normal
  375.  
  376. displayStatus: procedure expose status. mode.
  377.     parse arg status
  378.     address voicemail1 'displayStatus' status
  379.     return status.normal
  380.  
  381. displayMessage: procedure expose status. mode.
  382.     parse arg message
  383.     address voicemail1 'displayMessage' message
  384.     return status.normal
  385.  
  386. /* Effectively unlistens also! */
  387. setLastError: procedure expose status. mode.
  388.     parse arg status, error
  389.     address voicemail1 'setLastError' status ',' error
  390.     return status.normal
  391.  
  392. showDebugger: procedure
  393.     parse arg debuggerInfo
  394.     
  395.     firstLine = sourceline(1)
  396.     parse var firstLine '/*' title '*/'
  397.     if showlist('p', 'DEBUGGERLOGGER1') then
  398.         address debuggerLogger1 'e' title ':' debuggerInfo
  399.     else
  400.         say title ':' debuggerInfo
  401.     return
  402.  
  403. /*-----------------------------------------------------------------------*/
  404. /*                         signal processing                             */
  405. error:
  406.     call showDebugger("Error" rc "at line" sigl)
  407.     exit 20
  408.  
  409. break_c:
  410. halt:
  411.     call showDebugger("Halt/Break_C at line" sigl)
  412.     exit 20
  413.  
  414.  
  415. novalue:
  416.     call showDebugger("No value at line" sigl)
  417.     exit 20
  418.  
  419. syntax:
  420.     call showDebugger("Syntax error" rc "at line" sigl)
  421.     exit 20
  422.  
  423.  
  424. /* Initialize everything needed to communicate correctly with ZVM */
  425. doInitializations: procedure expose compression. mode. status. device. type. log.
  426.  
  427. log.incomingLog = 0
  428. log.archiveLog = 1
  429. log.outgoingLog = 2
  430. log.outgoingArchiveLog = 3
  431.  
  432. /* compressions */
  433. compression.ADPCM2 = 2
  434. compression.ADPCM3 = 3
  435. compression.CELP = 1
  436.  
  437. /* devices */
  438. device.telephoneLine = 2
  439. device.externalMic = 8
  440. device.internalSpeaker = 16
  441.  
  442. /* file types */
  443. type.unknownFile = 0
  444. type.zvmRawFile = 1
  445. type.zyxelFile = 2
  446. type.iffFaxFile = 3
  447. type.iff8svxFile = 4
  448.  
  449. /* modem modes */
  450. mode.unknownMode = -1
  451. mode.commandMode = 0
  452. mode.voiceMode = 1
  453. mode.connectedMode = 2
  454. mode.playMode = 3
  455. mode.recordMode = 4
  456.  
  457. /* return statuses from the various commands */
  458. status.normal = 0
  459. status.keyDetected = 1
  460. status.quietDetected = 2
  461. status.silenceDetected = 3
  462. status.faxDetected = 4
  463. status.busyDetected = 5
  464. status.timedOut = 6
  465. status.signalDetected = 7
  466. status.overflow = 8
  467. status.error = 9
  468.  
  469. call addlib("rexxsupport.library", 0, -30, 0)
  470.  
  471. return
  472.